package com.ex.ui.questionpanel;

import static org.junit.Assert.*;

import java.awt.Color;  
import javax.swing.JFrame; 
import org.fest.swing.fixture.FrameFixture;
import org.fest.swing.fixture.JButtonFixture; 
import org.fest.swing.fixture.JPanelFixture;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class TriangleJudgePanelTest {

	FrameFixture testFrame;
	JFrame objFrame;

	@Before
	public void setUp() throws Exception { 
		TriangleJudgePanel p = new TriangleJudgePanel(null);
		p.setVisible(true);
		p.setName("Judge");
		objFrame = new JFrame(); 
		objFrame.setSize(p.getWidth(), p.getHeight());
		objFrame.setContentPane(p);
		objFrame.setLocationRelativeTo(null); 
	 	objFrame.setVisible(true); 
		testFrame = new FrameFixture(objFrame);  
	}

	@After
	public void tearDown() throws Exception {
		objFrame.dispose();
		testFrame.cleanUp();
	}

	@Test
	public void testJudge() { 
		JPanelFixture panel = testFrame.panel("Judge");
		panel.radioButton("mYesBtn").requireSelected();
		panel.radioButton("mNoBtn").requireNotSelected();
		panel.checkBox("mAuto").click();
       
		 panel.textBox("mALengthTf").deleteText();
		 panel.textBox("mBLengthTf").deleteText();
		 panel.textBox("mCLengthTf").deleteText();
		
		 panel.textBox("mALengthTf").enterText("3");
		 panel.textBox("mBLengthTf").enterText("4");
		 panel.textBox("mCLengthTf").enterText("5");

		 JButtonFixture jbf = panel.button("mCommitBtn");
		 jbf.click();
		 panel.label("mRightAnswerTa").requireVisible();
		 assertEquals( Color.GREEN, panel.label("mRightAnswerTa").foreground().target());
		
	} 
 
}
